#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n;
    cin >> n;
    int ans = INT_MAX;
    while(n--) {
        int a, b;
        cin >> a >> b;
        ans = min(ans, a + (b - 1) / 2);
    }
    cout << ans << endl;
}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}